from sls_controller.sls_entity import EntityUpdate
from sls_controller.sls_publicResource import CrossResource
class CrossStatusEntityUpdate(EntityUpdate):
    def get_pub_topic(self):
        return "/pub/cross/vars" 
    
    def get_dict_data(self):
        return self.public_resource.cross_resource.to_dict()


#UAV.............................................
class BasicPositionEntityUpdate(EntityUpdate):
    def get_pub_topic(self):
        return "/status/"+self.public_resource.uav_resource.get_idStr()+"/BP" 
    
    def get_dict_data(self):
        return {
            "GNSS_position": self.public_resource.uav_resource.get_GNSS_position(),
            "vehicle_yaw": self.public_resource.uav_resource.get_vehicle_yaw(),
            "rel_alt": self.public_resource.uav_resource.get_relative_altitude()["NED"],
        }
    
class BasicStatusEntityUpdate(EntityUpdate):
    def get_pub_topic(self):
        return "/status/"+self.public_resource.uav_resource.get_idStr()+"/BS"
    
    def get_dict_data(self):
        return{
            #jugment related
            "is_flying": self.public_resource.uav_resource.is_flying_status(),
            "is_armed": self.public_resource.uav_resource.is_arming_status_armed(),
            #vehicle nav_state
            "is_offboard": self.public_resource.uav_resource.is_nav_state_offboard_mode(),            
        }
    
class StatusEntityUpdate(EntityUpdate):
    def get_pub_topic(self):
        return "/status/"+self.public_resource.uav_resource.get_idStr()+"/Status" 
    
    def get_dict_data(self):
        return {
                    #position velocity and yaw
                    "GNSS_position": self.public_resource.uav_resource.get_GNSS_position(),
                    "NED_position": self.public_resource.uav_resource.get_NED_position(),
                    "NED_velocity": self.public_resource.uav_resource.get_NED_velocity(),
                    "relative_altitude": self.public_resource.uav_resource.get_relative_altitude(),
                    "vehicle_yaw": self.public_resource.uav_resource.get_vehicle_yaw(),
                    #takeoff related
                    "takeoff_GNSS_position": self.public_resource.uav_resource.get_takeoff_GNSS_position(),
                    "takeoff_NED_position": self.public_resource.uav_resource.get_takeoff_NED_position(),
                    "takeoff_altitude": self.public_resource.uav_resource.get_takeoff_altitude(),
                    "takeoff_timestamp": self.public_resource.uav_resource.get_takeoff_time(),
                    #jugment related
                    "flying_status": self.public_resource.uav_resource.is_flying_status(),
                    "arming_status": self.public_resource.uav_resource.is_arming_status_armed(),
                    #vehicle attitude
                    "q_FRD_REFTO_NED": self.public_resource.uav_resource.get_q_FRD_REFTO_NED(),  # a list
                    #vehicle nav_state
                    "nav_state": self.public_resource.uav_resource.get_nav_state(),           
                }
